package com.church.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;

import com.church.services.QandaServices;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AddQuest extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 32L;
	private QandaServices qandaServices;
	private String subject;
	private String quest;
	private boolean response;

	public QandaServices getQandaServices() {
		return qandaServices;
	}

	public void setQandaServices(QandaServices qandaServices) {
		this.qandaServices = qandaServices;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getQuest() {
		return quest;
	}

	public void setQuest(String quest) {
		this.quest = quest;
	}

 

	public String execute() {
		ActionContext actionContext = ActionContext.getContext();
		Map session = actionContext.getSession();
		String userName = (String) session.get("USER_NAME");
		
		if (userName != null && subject != null && quest != null) {
			response = qandaServices.quest(subject, userName, quest).equals("success");
		}
		else
			response=false;
		return SUCCESS;
	}

	public boolean isResponse() {
		return response;
	}

	public void setResponse(boolean response) {
		this.response = response;
	}
	
}
